function factorial(n)
{
// If the number is not an integer, round it down. 
    n = Math.floor(n);

// The number must be equal to or bigger than zero 
    if (n < 0)
    {
        return "undefined";
    }

    if ((n == 0) || (n == 1))
    { // If the number is 0 or 1, its factorial is 1.
        return 1;
    }
    else 
    { // Make a recursive call 
        return (n * factorial(n - 1)); 
    } 

number = prompt("Enter a number:", "1")
document.write("<br> The Factorial is:");
document.write(factorial(number));
}
  
